<template>
  <view class="warn-item">
    <view class="header">
      <image
        class="icon-style"
        src="/static/images/message/tishi.png"
        mode="aspectFill"
      ></image>
      <view class="title">{{ data.title || '--' }}</view>
    </view>
    <view class="warn-row">
      <text class="sub-title">报警时间:</text>
      <text class="content">{{ data.alarmTime || '--' }}</text>
    </view>
    <view class="warn-row" v-if="data.sourceType == 2">
      <text class="sub-title">监测设备:</text>
      <text class="content">{{ data.monitorDeviceName || '--' }}</text>
    </view>
    <view class="warn-row">
      <text class="sub-title">报警内容:</text>
      <text class="content">{{ data.content || '--' }}</text>
    </view>
    <view class="warn-bottom">
      <view class="flex-row flex-auto justify-end">
        <view class="warn-btn warn-btn-active" @click="goHandleEvent(data.id)">处理</view>
      </view>
    </view>
  </view>
</template>

<script>
export default {
  props: {
    data: {
      type: Object,
      default: () => ({}),
    },
  },
  methods: {
    goHandleEvent(id) {
      uni.navigateTo({
        url: `/pages/work/warnEvent/handleEvent?id=${id}`,
      });
    },
  },
};
</script>

<style lang="scss" scoped>
.warn-item {
  background: #ffffff;
  border-radius: 20rpx 20rpx 20rpx 20rpx;
  padding: 30rpx 30rpx 20rpx 30rpx;
  margin: 0 30rpx;
  .header {
    display: flex;
    align-items: center;
    margin-bottom: 30rpx;
    .icon-style {
      width: 52rpx;
      height: 52rpx;
      margin-right: 20rpx;
    }
    .title {
      font-size: 32rpx;
      font-weight: 700;
      flex: 1;
    }
  }
}

.warn-row {
  color: #999999;
  margin-bottom: 20rpx;
  display: flex;
  .sub-title {
    display: inline-block;
    width: 130rpx;
  }
  .content {
    flex: 1;
    word-break: break-all;
    color: #333;
  }
}

.warn-bottom {
  border-top: 1rpx solid #d5d7e3;
  display: flex;
  align-items: center;
  padding-top: 20rpx;
  justify-content: space-between;
  .warn-btn {
    width: 140rpx;
    height: 60rpx;
    border-radius: 32rpx 32rpx 32rpx 32rpx;
    opacity: 1;
    border: 1rpx solid #c87c32;
    font-size: 28rpx;
    color: #c87c32;
    text-align: center;
    line-height: 60rpx;
    margin-left: 20rpx;
  }

  .warn-btn-active {
    color: #454a5e;
    border-color: #454a5e;
    margin-left: 0;
  }
}
</style>
